#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time: 2019/4/9  23:29
# @Author: 余浪人
# @email: yulangren520@gmail.com

from apps.models import db, BaseModel

# 等级模型
class Grade(BaseModel):
    grade_name = db.Column(db.String(512), comment='等级名称')
    grade_scope = db.Column(db.String(512), comment='积分范围')

    def __repr__(self):
        return f'等级:<{self.grade_name}>'

    def keys(self):
        return 'grade_name', 'grade_scope',


# 会员模型
class Member(BaseModel):
    username = db.Column(db.String(32), comment='用户名')
    gender = db.Column(db.Integer,default=1, comment='性别 1|保密/2|男/3|女')
    qq = db.Column(db.String(15), comment='QQ')
    email = db.Column(db.String(128), comment='邮箱')
    password = db.Column(db.String(512), comment='密码')
    credits = db.Column(db.Integer,default=200, comment='总积分')
    authority = db.Column(db.Integer,default=0, comment='发布权限 1|开启发布文章/0|关闭发布文章')

    def __repr__(self):
        return f'会员:<{self.username}>'

    def keys(self):
        return 'username', 'gender', 'qq', 'email', 'credits', 'authority',
